<template>
  <el-card>
    <el-table
      :data="permissionList"
      border
      lazy
      ref="categoryRef"
      row-key="id"
      :expand-row-keys="['1']"
    >
      <el-table-column label="名称" prop="name"></el-table-column>
      <el-table-column label="权限值" prop="code"></el-table-column>
      <el-table-column label="跳转权限值" prop="toCode"></el-table-column>
      <el-table-column align="center" label="操作">
        <template v-slot="{ row }">
          <el-button
            type="primary"
            :icon="Plus"
            size="small"
            title="添加"
            :disabled="row.level === 3"
          ></el-button>
          <el-button
            type="warning"
            :icon="Edit"
            size="small"
            title="修改"
          ></el-button>
          <el-popconfirm
            width="220"
            :icon="InfoFilled"
            icon-color="#626AEF"
            :title="`您确定要删除吗？`"
          >
            <template #reference>
              <el-button
                type="danger"
                :icon="Delete"
                size="small"
                title="删除"
              />
            </template>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script lang="ts">
export default {
  name: "XPermission",
};
</script>

<script lang="ts" setup>
import { Plus, Edit, Delete, InfoFilled } from "@element-plus/icons-vue";
import { PermissionList } from "@/api/acl/model/roleModel";
import { ref, onMounted } from "vue";
import { GetPermissionListApi } from "@/api/acl/permission";

const permissionList = ref<PermissionList>([]);

onMounted(async () => {
  const res = await GetPermissionListApi();
  permissionList.value = res.children;
});
</script>

<style scoped></style>
